<template>
  <div class="fang">
    <header>
      <div class="forms">
        <van-icon name="arrow-left" />
        <div class="sear">
          <span @click="hanldeGo1">{{city.label}}<i class="iconfont icon-triangle-down"></i></span>
          <form action="">
            <i class="iconfont icon-fangdajing"></i>
            <input type="text" placeholder="请输入小区或地址" />
          </form>
        </div>
        <i class="iconfont icon-dizhi-01"></i>
      </div>
    </header>
    <main>
      <!-- 四个一排点击 -->
      <div class="si">
        <li>区域<i class="iconfont icon-triangle-down"></i></li>
        <li>方式<i class="iconfont icon-triangle-down"></i></li>
        <li>租金<i class="iconfont icon-triangle-down"></i></li>
        <li>筛选<i class="iconfont icon-triangle-down"></i></li>
      </div>
      <!-- 图文混排 -->
    <div class="hun">
      <dl v-for=" v in houses" :key="v.id">
        <dt >
          <img :src="v.houseImg" alt="">
        </dt>
        <dd @click="handleDetail(v)">
          <h3>{{v.desc}}</h3>
          <p>{{v.title}}</p>
          <span>{{v.tags[0]}}</span>

          <b>{{v.price}}元/月</b>
        </dd>
      </dl>
    </div>
     
    </main>
  </div>
</template>

<script>

import axios from "../utils/request";
import {mapState} from "vuex";
export default {
  data() {
    return {
      houses: [],
      
    };
  },
  created() {
    /// vant轻提示
    this.getHouse();
  
  },
  computed:{
...mapState(['city'])
  },
  methods:{
    getHouse(){
      axios.get(`/houses?cityId=${this.city.value}`).then(res=>{
        // console.log(res,'222');
        if(res.data.status===200){
          this.houses=res.data.body.list;
        }
      })
    },
    hanldeGo1(){
      this.$router.go(-1);
    },
    handleDetail(v){
      console.log(v)
     this.$router.push({path:"/detail",query:{id:v.houseCode}});

    }
  }
  
  
};
</script>

<style lang='scss' scoped>
.fang {
  width: 100%;
  height: 100%;
  background-color: #f2f2f2;
  header {
    width: 100%;
    height: 1rem;
    border-bottom: 1px solid #ccc;
    padding: 0 0.1rem;
  }
}
.forms {
  width: 100%;
  height: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .sear {
    flex: 1;
    display: flex;
    align-items: center;
    background-color: #fff;
    border-radius: 0.05rem;
    span {
      width: 1.5rem;
      text-align: center;
      i {
        color: #000;
      }
    }
    form {
      flex: 1;
      display: flex;
      align-items: center;
      border-radius: 0.12rem;
      i {
        width: 0.4rem;
        text-align: center;
        color: #000;
      }
      input {
        flex: 1;
        height: 0.64rem;
        border: none;
        outline: none;
      }
    }
  }
  i {
    margin: 0 0.1rem;
    color: #000;
    font-size: 16px;
  }
}
main {
  background-color: #fff;
}
.van-dropdown-menu {
  width: 100%;
  height: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #eee;
  .van-dropdown-item {
    width: 100px;
  }
}
.style-btnBox {
  width: 100%;
  height: 1rem;
  display: flex;
  align-items: center;
  border-top: 1px solid #eee;
  .style-cancel {
    text-align: center;
    box-sizing: border-box;
    flex: 1;
    margin-left: 0.16rem;
    min-width: 0.2rem;
  }
  .style-submit {
    flex: 1;
    height: 1rem;
    line-height: 1rem;
    text-align: center;
    color: #fff;
    background-color: #21b97a;
  }
}
.van-popup {
  height: 100%;
  background-color: #afb2b3;
}
.rowgroup {
  width: 100%;
  height: auto;
  dl {
    width: 100%;
    height: 2.4rem;
    display: flex;
    align-items: center;
    padding: 0.2rem;
    border-bottom: 1px solid #eee;
    dt {
      width: 2.1rem;
      height: 100%;
      margin: 0 0.2rem;
      img {
        width: 2.1rem;
        height: 1.6rem;
      }
    }
    dd {
      flex: 1;
      h3 {
        font-size: 15px;
        letter-spacing: 0;
        overflow: hidden;
        // text-overflow: ellipsis;
        // white-space: nowrap;
        // vertical-align: middle;
      }
      p {
        font-size: 12px;
        color: #afb2b3;
        padding: 0.2rem 0;
      }
      span {
        color: #fa5741;
      }
    }
  }
}
.si{
  width: 100%;
  padding: 10px;
  display: flex;
  justify-content: space-around;
  border-bottom: 1px solid #ccc;
}
.hun{
  width: 100%;
  padding: 10px;
  dl{
    display: flex;
    padding: 10px;
    border-bottom: 1px solid #ccc;
    dt {
      width: 100px;
      height: 80px;
      img{
        width: 100%;
        height: 100%;
      }
    }
    dd{
      display: block;
      margin-left: 14px;
      line-height: 22px;
      span{
        padding: 4px;
        background:  aquamarine;
      
      }
      b{
        display: block;
        color:red;
        font-size: 14px;
      }
    }
  }
}
</style>